package com.tianque.wgxy.h5sdkdemo;

import android.app.Application;
import android.util.Log;

import com.tianque.wgxy.h5container.h5sdk.pojo.UserInfo;
import com.tianque.wgxy.h5container.h5sdk.utils.H5ContainerUtils;


public class App extends Application {
    private static final String TAG = "Application";

    @Override
    public void onCreate() {
        super.onCreate();
        cacheHandle();
        initH5Container();
    }

    /**
     * 初始化h5容器
     */
    private void initH5Container() {
        Log.e(TAG, "initH5Container");
        H5ContainerUtils.initH5ContainerConfig(this,"189fd83615aa449f9d9951af521a3858","87afdfd4d3cc444785091c8510ae27a2");
        //todo 设置获取用户信息回调,调试阶段可以先使用下面配置.真实场景应该在APP获取用户信息时添加如下设置,字段目前还未确定下面字段仅用于调试
//        H5ContainerUtils.setProviderUserInfoCallback(() -> new UserInfo("测试", "123456", "18523299305"));
    }

    private void cacheHandle() {
        //记录崩溃信息
        final Thread.UncaughtExceptionHandler defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread thread, Throwable throwable) {

                //最后如何处理这个崩溃，这里使用默认的处理方式让APP停止运行
//                defaultHandler.uncaughtException(thread, throwable);
            }
        });
    }
}
